--------------------------------------------------------------------- --'Helicopter -- edited by Alundaio for smart_terrain usage -- class has no update function, need to spoof this in actor update se_helicopters = {} class "se_heli" (cse_alife_helicopter) function se_heli:__init (section) super (section) end function se_heli:on_register() cse_alife_helicopter.on_register(self) -- Проверяем кастомдату обьекта на наличие стори айди. SendScriptCallback("server_entity_on_register",self,"se_heli") se_helicopters[self.id] = self self.player_id = ini_sys:r_string_ex(self:section_name(),"player_id") or "heli" self.community = ini_sys:r_string_ex(self:section_name(),"faction") or "heli" end function se_heli:on_unregister() SendScriptCallback("server_entity_on_unregister",self,"se_heli") se_helicopters[self.id] = nil --printf("unregister heli %s",self.respawn_point_id) if (self.respawn_point_id and self.respawn_point_prop_section) then local smart = alife_object(self.respawn_point_id) if smart == nil then return end smart.already_spawned[self.respawn_point_prop_section].num = smart.already_spawned[self.respawn_point_prop_section].num - 1 end local strn_id = self.m_smart_terrain_id if strn_id and strn_id ~= 65535 then local smart = alife_object(strn_id) if smart ~= nil then smart:unregister_npc(self) end end cse_alife_helicopter.on_unregister(self) end function se_heli:can_switch_online() return cse_alife_helicopter.can_switch_online(self) end function se_heli:clear_smart_terrain() self.m_smart_terrain_id = nil local st = db.storage[self.id] if (st and st.object) then xr_logic.reset_logic(st.object,st) end end function se_heli:STATE_Write(packet) cse_alife_helicopter.STATE_Write(self,packet) --printf("STATE_Write %s",self.respawn_point_id) if (self.respawn_point_prop_section) then packet:w_u16(self.assigned_target_id or 65535) packet:w_u16(self.current_target_id or 65535) packet:w_u16(self.m_smart_terrain_id or 65535) packet:w_u16(self.respawn_point_id or 65535) packet:w_stringZ(tostring(self.respawn_point_prop_section)) end end function se_heli:STATE_Read(packet,size) cse_alife_helicopter.STATE_Read(self, packet, size) --printf("size=%s elapsed=%s",size,packet:r_elapsed()) if (packet:r_elapsed() > 0) then self.assigned_target_id = packet:r_u16() if (self.assigned_target_id == 65535) then self.assigned_target_id = nil end self.current_target_id = packet:r_u16() if (self.current_target_id == 65535) then self.current_target_id = nil end self.m_smart_terrain_id = packet:r_u16() if (self.m_smart_terrain_id == 65535) then self.m_smart_terrain_id = nil end self.respawn_point_id = packet:r_u16() if (self.respawn_point_id == 65535) then self.respawn_point_id = nil end self.respawn_point_prop_section = packet:r_stringZ() if (self.respawn_point_prop_section == "nil") then self.respawn_point_prop_section = nil end end end function se_heli:keep_saved_data_anyway() return true end